<%@ page contentType="text/html; charset=utf-8" language="java"%>
<%@ include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>管理中心 - 定义表单</title>
	<%@ include file="/common/meta.jsp" %>
	<link href="${ctx}/css/system/general.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/main.css" rel="stylesheet" type="text/css" />
	<link href="${ctx}/css/system/category.css" rel="StyleSheet" type="text/css" />	
	<link href="${ctx}/css/system/dtree.css" rel="StyleSheet" type="text/css" />	
	<script type="text/javascript" src="${ctx}/js/jquery-1.4.min.js"></script>
	<script type="text/javascript">
	function changeInputType(thisVar){
	   if(thisVar.value!="文本输入框"){
	       $("#propertyValueTr").show();
	   }else{
	       $("#propertyValueTr").hide();
	       var propertyValues = document.getElementsByName("propertyValue");
	       if(propertyValues!=null && propertyValues.length>1){
	          for(i=0;i<propertyValues.length;i++){
	             propertyValues[i].value = "";
	          }
	       }
	   }
	}
	 function addPropertyValue(){
	    $("#propertyValue-table tr:last").after("<tr><td> <input type=\"text\"  size=\"20\" maxlength=\"32\" name=\"propertyValue\"/> <a onclick=\"removePropertyValue(this)\" href=\"javascript:;\" title=\"删除\">[删除]</a></td></tr>");	
	 }
	 function removePropertyValue(obj){
	    $(obj.parentNode.parentNode).remove();
	 }
	</script>
</head>
<body>
<h1>
<span class="action-span"><a href="${ctx}/system/workflow/form/list/${workFlowId}">表单列表</a></span>
<span class="action-span1"><a href="#">管理中心</a>  - 定义表单 </span>
<div style="clear:both"></div>
</h1>

<div class="main-div">
  <form:form  modelAttribute="workFlowForm" action="${ctx}/system/workflow/form/update" method="post" name="theForm" id="theForm" onsubmit="this.submit.disabled='true';">
  <input type="hidden" name="workFlowId" id="workFlowId" value="${workFlowForm.workFlow.id}"/>
  <input type="hidden" name="id" id="id" value="${workFlowForm.id}"/>
  <table width="100%" id="general-table">
      <tr>
        <td class="label">标签</td>
        <td>
        <input type="text" name="label" id="label" maxlength="32" value="${workFlowForm.label}"/>
        </td>
      </tr>
      <tr>
        <td class="label">名称</td>
        <td>
        <input type="text" name="name" id="name" maxlength="32" value="${workFlowForm.name}"/>
        </td>
      </tr>
      <tr>
        <td class="label">类型</td>
        <td>
        <select name="type" id="type">
           <c:choose>
              <c:when test="${workFlowForm.type=='字符串'}">
           <option selected="selected" value="字符串">字符串</option>
           <option value="整数">整数</option>
           <option value="浮点数">浮点数</option>
           <option value="文件">文件</option>
              </c:when>
              <c:when test="${workFlowForm.type=='浮点数'}">
           <option value="字符串">字符串</option>
           <option value="整数">整数</option>
           <option selected="selected" value="浮点数">浮点数</option>
           <option value="文件">文件</option>
              </c:when>
              <c:when test="${workFlowForm.type=='文件'}">
           <option value="字符串">字符串</option>
           <option value="整数">整数</option>
           <option value="浮点数">浮点数</option>
           <option selected="selected" value="文件">文件</option>
              </c:when>
              <c:when test="${workFlowForm.type=='整数'}">
           <option value="字符串">字符串</option>
           <option selected="selected" value="整数">整数</option>
           <option value="浮点数">浮点数</option>
           <option value="文件">文件</option>
              </c:when>
              <c:otherwise>
           <option selected="selected" value="字符串">字符串</option>
           <option value="整数">整数</option>
           <option value="浮点数">浮点数</option>
           <option value="文件">文件</option>
              </c:otherwise>
           </c:choose>
        </select>
        </td>
      </tr>
      <tr>
        <td class="label">输入形式<br /></td>
        <td>
        <select name="inputType" id="inputType" onchange="changeInputType(this)">
           <c:choose>
              <c:when test="${workFlowForm.inputType=='文本输入框'}">
           <option selected="selected" value="文本输入框">文本输入框</option>
           <option value="下拉选择框">下拉选择框</option>
           <option value="多选复选框">多选复选框</option>
           <option value="单选按钮">单选按钮</option>
              </c:when>
              <c:when test="${workFlowForm.inputType=='下拉选择框'}">
           <option value="文本输入框">文本输入框</option>
           <option selected="selected" value="下拉选择框">下拉选择框</option>
           <option value="多选复选框">多选复选框</option>
           <option value="单选按钮">单选按钮</option>
              </c:when>
              <c:when test="${workFlowForm.inputType=='多选复选框'}">
           <option value="文本输入框">文本输入框</option>
           <option value="下拉选择框">下拉选择框</option>
           <option selected="selected" value="多选复选框">多选复选框</option>
           <option value="单选按钮">单选按钮</option>
              </c:when>
              <c:when test="${workFlowForm.inputType=='单选按钮'}">
           <option value="文本输入框">文本输入框</option>
           <option value="下拉选择框">下拉选择框</option>
           <option value="多选复选框">多选复选框</option>
           <option selected="selected" value="单选按钮">单选按钮</option>
              </c:when>
              <c:otherwise>
           <option value="文本输入框">文本输入框</option>
           <option value="下拉选择框">下拉选择框</option>
           <option value="多选复选框">多选复选框</option>
           <option value="单选按钮">单选按钮</option>
              </c:otherwise>
           </c:choose>
        </select>
        </td>
      </tr>
      <tr id="propertyValueTr" <c:if test="${workFlowForm.inputType=='文本输入框'}">style="display:none"</c:if>>
        <td class="label">可选值列表</td>
        <td>
		  <table align="left" width="90%" id="propertyValue-table" style="margin:0;">
			    <c:forEach items="${workFlowForm.formProperties}" var="varTemp" varStatus="varStatusTemp">
			     <c:choose>
			     <c:when test="${varStatusTemp.index==0}">
			 <tr>            
			    <td>
			     <input type="text" size="20" maxlength="32" name="propertyValue" value="${varTemp.value}"/> <a onclick="addPropertyValue()" href="javascript:;" title="添加表单属性值">[添加]</a>
	            </td>
			 </tr>
			     </c:when>
			     <c:otherwise>
			 <tr>            
			    <td>
				<input type="text" size="20" maxlength="32" name="propertyValue" value="${varTemp.value}"/> <a onclick="removePropertyValue(this)" href="javascript:;" title="删除表单属性值">[删除]</a>
	            </td>
			 </tr>
			     </c:otherwise>
			     </c:choose>
			    </c:forEach>
		 </table>
        </td>
      </tr>
  </table>
      <div class="button-div">
        <input type="submit" value=" 确定 " />
      </div>
  </form:form>
</div>
</body>
</html>